﻿@model AddressModel
@using Nop.Web.Models.Common;

@if (Model.CountryEnabled && Model.StateProvinceEnabled)
{
    <script type="text/javascript">
        $(function () {
            $("#@Html.FieldIdFor(model => model.CountryId)").change(function () {
                var selectedItem = $(this).val();
                var ddlStates = $("#@Html.FieldIdFor(model => model.StateProvinceId)");
                var statesProgress = $("#states-loading-progress");
                statesProgress.show();
                $.ajax({
                    cache: false,
                    type: "GET",
                    url: "@(Url.RouteUrl("GetStatesByCountryId"))",
                    data: { "countryId": selectedItem, "addSelectStateItem": "true" },
                    success: function (data) {
                        ddlStates.html('');
                        $.each(data, function (id, option) {
                            ddlStates.append($('<option></option>').val(option.id).html(option.name));
                        });
                        statesProgress.hide();
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert('Failed to retrieve states.');
                        statesProgress.hide();
                    }
                });
            });
        });
    </script>
}
@Html.HiddenFor(model => model.Id)
<div class="form-horizontal">
    <div class="form-group">


        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
            <div class="">
                @Html.LabelFor(model => model.FirstName, new { @class = "" }, " :")
                @Html.RequiredHint()
            </div>
        </div>
        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            @Html.TextBoxFor(model => model.FirstName, new { @class = "gray-input", autofocus = "autofocus" })
        </div>
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
            @Html.ValidationMessageFor(model => model.FirstName, string.Empty, new { @class = "text-danger" })
        </div>
    </div>
    <div class="form-group inputs">


        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
            <div class="">
                @Html.LabelFor(model => model.LastName, new { @class = "" }, " :")
                @Html.RequiredHint()
            </div>
        </div>
        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            @Html.TextBoxFor(model => model.LastName, new { @class = "gray-input", autofocus = "autofocus" })
        </div>
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
            @Html.ValidationMessageFor(model => model.LastName, string.Empty, new { @class = "text-danger" })
        </div>
    </div>
    <div class="form-group inputs">


        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
            <div class="">
                @Html.LabelFor(model => model.Email, new { @class = "" }, " :")
                @Html.RequiredHint()
            </div>
        </div>
        <div class="col-lg-6 col-md-9 col-sm-9 col-xs-9">
            @Html.TextBoxFor(model => model.Email, new { @class = "gray-input", autofocus = "autofocus" })
        </div>
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
            @Html.ValidationMessageFor(model => model.Email, string.Empty, new { @class = "text-danger" })
        </div>
    </div>
    @if (Model.CompanyEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                <div class="">
                    @Html.LabelFor(model => model.Company, new { @class = "" }, " :")
                    @if (Model.CompanyRequired)
                    {
                        @Html.RequiredHint()
                    }
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.TextBoxFor(model => model.Company, new { @class = "gray-input", autofocus = "autofocus" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.Company, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }
    @if (Model.CountryEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 ">
                <div class="">
                    @Html.LabelFor(model => model.CountryId, new { @class = "" }, " :")
                    @Html.RequiredHint()
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.DropDownList("CountryId", Model.AvailableCountries, new { @class = "gray-dropdown" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.CountryId, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }

    @if (Model.CountryEnabled && Model.StateProvinceEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                <div class="">
                    @Html.LabelFor(model => model.StateProvinceId, new { @class = "control-label" }, " :")
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.DropDownList("StateProvinceId", Model.AvailableStates, new { @class = "gray-dropdown" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                <span id="states-loading-progress" style="display: none;" class="text-info">@T("Common.Wait...")</span>
            </div>

            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.StateProvinceId, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }
    @if (Model.CityEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                <div class="">
                    @Html.LabelFor(model => model.City, new { @class = "" }, " :")
                    @if (Model.CityRequired)
                    {
                        @Html.RequiredHint()
                    }
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.TextBoxFor(model => model.City, new { @class = "gray-input", autofocus = "autofocus" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.City, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }
    @if (Model.StreetAddressEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                <div class="">
                    @Html.LabelFor(model => model.Address1, new { @class = "" }, " :")
                    @if (Model.StreetAddressRequired)
                    {
                        @Html.RequiredHint()
                    }
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.TextBoxFor(model => model.Address1, new { @class = "gray-input", autofocus = "autofocus" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.Address1, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }
    @if (Model.StreetAddress2Enabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                <div class="">
                    @Html.LabelFor(model => model.Address2, new { @class = "control-label" }, " :")
                    @if (Model.StreetAddress2Required)
                    {
                        @Html.RequiredHint()
                    }
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.TextBoxFor(model => model.Address2, new { @class = "gray-input", autofocus = "autofocus" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.Address2, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }
    @if (Model.ZipPostalCodeEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 ">
                <div class="">
                    @Html.LabelFor(model => model.ZipPostalCode, new { @class = "control-label" }, " :")
                    @if (Model.ZipPostalCodeRequired)
                    {
                        @Html.RequiredHint()
                    }
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.TextBoxFor(model => model.ZipPostalCode, new { @class = "gray-input", autofocus = "autofocus" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.ZipPostalCode, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }
    @if (Model.PhoneEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                <div class="">
                    @Html.LabelFor(model => model.PhoneNumber, new { @class = "control-label" }, " :")
                    @if (Model.PhoneRequired)
                    {
                        @Html.RequiredHint()
                    }
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.TextBoxFor(model => model.PhoneNumber, new { @class = "gray-input", autofocus = "autofocus" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.PhoneNumber, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }
    @if (Model.FaxEnabled)
    {
        <div class="form-group inputs">


            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 ">
                <div class="">
                    @Html.LabelFor(model => model.FaxNumber, new { @class = "control-label" }, " :")
                    @if (Model.FaxRequired)
                    {
                        @Html.RequiredHint()
                    }
                </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                @Html.TextBoxFor(model => model.FaxNumber, new { @class = "gray-input", autofocus = "autofocus" })
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left">
                @Html.ValidationMessageFor(model => model.FaxNumber, string.Empty, new { @class = "text-danger" })
            </div>
        </div>
    }

    @if (Model.CustomAddressAttributes.Count > 0)
    {
        @Html.Partial("_AddressAttributes", Model.CustomAddressAttributes)
    }
</div>
